using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using csvviewer.contracts;
using csvviewer.adapter;

namespace csvviewer.logic
{
    public class Get_page_from_buffer
    {
		public Get_page_from_buffer(Calc_index_of_first_line_of_page calc, 
			                        Get_page_line_positions_from_buffer getLines,
			                        Read_page_lines_from_file read)
		{
			_turnToPage = calc.Process;
			_jumpToPage = calc.Process;
			
			calc.Result += getLines.Process;
			getLines.Page += read.Process;
			read.Page += _ => this.Page(_);
		}
		
		private Action<PageDirections> _turnToPage;
        public void TurnToPage(PageDirections pageDirection)
        {
            _turnToPage(pageDirection);
        }
		
		private Action<int> _jumpToPage;
		public void JumpToPage(int pageNo)
		{
			_jumpToPage(pageNo);
		}

        public event Action<PageOfLines> Page;
    }
}
